package com.atguigu.springcloud.controller;

import com.netflix.appinfo.InstanceInfo;
import com.netflix.discovery.EurekaClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Test {
    @Autowired
    private EurekaClient discoveryClient;

    @GetMapping("/test")
    public String serviceUrl() {
        try {

            InstanceInfo instance = discoveryClient.getNextServerFromEureka("bbbb", false);
            return instance.getHomePageUrl();
        } catch (Exception e) {
            e.fillInStackTrace();
            throw e;
        }
    }
}
